package com.yunchao.test.data

import androidx.room.Room
import com.yunchao.test.data.datasource.MaintenanceDatabase
import com.yunchao.test.data.repository.LockToolRepositoryImpl
import com.yunchao.test.data.repository.MaintenanceInfoRepositoryImpl
import com.yunchao.test.domain.repository.LockToolRepository
import com.yunchao.test.domain.repository.MaintenanceInfoRepository
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module

val dataModule = module {
    // 提供数据库实例
    single {
        Room.databaseBuilder(
            androidContext(),
            MaintenanceDatabase::class.java,
            "lock_test_db"
        ).build()
    }

    // 提供 DAO 实例
    single { get<MaintenanceDatabase>().maintenanceInfoDao() }

    single<MaintenanceInfoRepository> { MaintenanceInfoRepositoryImpl(androidContext(), get()) }
    single<LockToolRepository> { LockToolRepositoryImpl(get(), get()) }
}